package com.fl.controller;

import com.alibaba.fastjson.JSON;
import com.fl.dto.OrdersDo;
import com.fl.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
public class UrlController {

    @Autowired
    private OrdersService ordersService;

    @GetMapping("/success")
    @ResponseBody
    public String success(){
        return "成功付款";
    }

    @PostMapping("/nodify")
    public void nodify(HttpServletRequest request){
        String out_trade_no = request.getParameter("out_trade_no");
        float total_amount = Float.valueOf(request.getParameter("total_amount"));
//        List<String> list = JSON.parseArray(goods_detail, String.class);
        int count = 1;
        OrdersDo ordersDo = ordersService.save(out_trade_no, "213142142121", count, total_amount);
        System.out.println(ordersDo);
    }
}
